/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package modelo;
/*
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;



/**
 *
 * @author igovan
 */

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.AnnotationConfiguration;


public class HibernateUtil
{
    private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
    private static HibernateUtil instance = null;
    private SessionFactory sessionFactory = null;

    /**
     * Constructor para ConnectionFactory
     */
    private HibernateUtil()
    {
        try
        {
            Configuration cfg=new Configuration();
            cfg.configure(CONFIG_FILE_LOCATION);
            sessionFactory = cfg.buildSessionFactory();
        }
        catch (Exception e)
        {
            System.out.println(e);
        }
    }

    /**
     * Devuelve una Ãºnica instancia de la clase
     * @return ConnectionFactory
     */
    public static synchronized HibernateUtil getInstance()
    {
        if (instance == null)
        {
            instance = (HibernateUtil) new HibernateUtil();
        }
        return instance;
    }

    /**
     * Devuelve la sesiÃ³n activa
     * @return Session
     */
    public Session getSession()
    {
        try
        {
            Session s = sessionFactory.openSession();
            return s;
        }
        catch (Exception e)
        {
            System.out.println(e);
            throw new RuntimeException(e);
        }
    }
}